git基本用法

git的简单使用

git基本用法

1
2
3
4
5
6
7
8
9
10
11
12
graph LR
subgraph 工作区
a[a1.txt]
end
subgraph 缓冲区
b[a1.txt]
end
subgraph 版本库
c[a1.txt]
end
a--git add-->b
b--git commit-->c
1
2
3
4
5
6
7
8
graph LR
a[init]
b[config]
c[add]
d[commit]
a-->b
b-->c
c-->d

git init

初始化git仓库

把当前目录当作工作区

出现 .git 文件夹

git config

配置开发者名字

git config –global user.name Hayden

配置邮箱

git config –global user.email xxxxx@xxx.com

git config –list

地址~/.gitconfig

git add

把工作区中未被追踪的文件添加到暂存区,文件变为暂存状态

git add filename

将文件添加到暂存区

git add .

将工作目录下所有修改的文件添加到暂存区

git commit

git commit

git commit -m ‘description’

将暂存区内的文件提交到版本库

git commit -am ‘description’

跳过git add添加到暂存区命令

直接将工作区所有已跟踪的文件提交

git log

-1

-2

-p

–oneline 只显示前7位提交码

git status

查看项目文件状态

-u

忽略规则

创建.gitignore文件 写入要忽略的文件或文件名

支持通配符


图形界面 gitk